package com.zqk.pattern.creational.singleton.hungrysingleton;


import java.io.*;

/**
 * @Package com.zqk.pattern.creational.singleton
 * @Description:TODO
 * @Author 张乾坤
 * @Create: 2018/10/26
 * @Version 1.0
 * @Update: message
 */
public class Test {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        HungrySingleton hungrySingleton = HungrySingleton.getInstance();


            ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("aaa"));
            oos.writeObject(hungrySingleton);
            File file = new File("aaa");

            ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
            HungrySingleton newObject = (HungrySingleton) ois.readObject();
            System.out.println(hungrySingleton);
            System.out.println(newObject);
            System.out.println(hungrySingleton == newObject);
        }
    }
